﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Easyui扩展库 Combo - 落阳 整理</title>
    <link href="http://www.easyui-extlib.com/Content/Site.css" rel="stylesheet" />
    <script src="http://www.easyui-extlib.com/Scripts/jquery/jquery-1.11.0.min.js"></script>
    <script src="http://www.easyui-extlib.com/Scripts/jquery-extensions/jquery.jdirk.js"></script>
    <link href="http://www.easyui-extlib.com/Scripts/jquery-easyui/jquery-easyui-1.4.3/themes/default/easyui.css" rel="stylesheet" />
    <link href="http://www.easyui-extlib.com/Scripts/jquery-easyui/jquery-easyui-1.4.3/themes/icon.css" rel="stylesheet" />
    <script src="http://www.easyui-extlib.com/Scripts/jquery-easyui/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
    <script src="http://www.easyui-extlib.com/Scripts/jquery-easyui/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"></script>

    <script src="http://www.easyui-extlib.com/Scripts/jquery-easyui-extensions/combo/jeasyui.extensions.combo.setRequired.js"></script>
    <script>
        $(function () {

            $('#cc').combo({
                editable: false,
                required: true,
                iconCls: 'icon-save'
            });
            $('#sp').appendTo($('#cc').combo('panel'));
            $('#sp input').click(function () {
                var v = $(this).val();
                var s = $(this).next('span').text();
                $('#cc').combo('setValue', v).combo('setText', s).combo('hidePanel');
            });

            $("#btnSet").click(function () {
                var value = $("[name='requiredValue']:checked").val();
                $("#cc").combo("setRequired", $.string.toBoolean(value));
            });

            $("#btnValid").click(function () {
                var ret = $("#cc").combo("isValid");
                alert(ret);
            });

        });
    </script>
</head>
<body>
    <div class="easyui-panel" data-options="fit:true,border:false" style="padding:20px;">
        <select id="cc" style="width:150px"></select>
        <div id="sp">
            <div style="color:#99BBE8;background:#fafafa;padding:5px;">Select a language</div>
            <div style="padding:10px">
                <input type="radio" name="lang" value="01"><span>Java</span><br />
                <input type="radio" name="lang" value="02"><span>C#</span><br />
                <input type="radio" name="lang" value="03"><span>Ruby</span><br />
                <input type="radio" name="lang" value="04"><span>Basic</span><br />
                <input type="radio" name="lang" value="05"><span>Fortran</span>
            </div>
        </div>
        <br />
        <br />
        <input name="requiredValue" type="radio" value="true" /> required 为 true，不能为空 &nbsp;
        <input name="requiredValue" type="radio" value="false" checked="checked" /> required 为 false，可以为空 &nbsp;
        <span style="color:red;">请自行选择要设置给上述 combo 的 required 值</span>
        <br />
        <a id="btnSet" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">设置新的 required 值</a>
        <br /><br />
        <a id="btnValid" class="easyui-linkbutton" data-options="iconCls:'icon-add'">对 combo 进行验证</a>
    </div>
</body>
</html>
